package cn.shop.core.service.impl;

import cn.shop.core.bean.OrderDetail;
import cn.shop.core.bean.OrderManagement;
import cn.shop.core.dao.OrderDetailDAO;
import cn.shop.core.dao.OrderManagementDAO;
import cn.shop.core.service.OrderMangamentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;



@Service
@Transactional
public class OrderMangamentServiceImpl implements OrderMangamentService {

	/**
	 * 订单管理数据访问接口
	 */
	@Autowired
	private OrderManagementDAO omdao;
	
	/**
	 * 订单明细的数据访问接口
	 */
	@Autowired
	private OrderDetailDAO oddao;
	
	public void add(OrderManagement om, List<OrderDetail>  list) {
		
		//添加订单
		int count = omdao.addorder(om);
		
		//订单明细
		if(count>0){
			for(OrderDetail od :list){
				od.setOrderId(om.getOrderId());
				oddao.add(od);
			}
		}else{
			
			throw new RuntimeException();
		}
	
		
	}

	public List<Map> list(OrderManagement om) {
		// TODO Auto-generated method stub
		return omdao.list(om);
	}

	public List<Map> detailslist(OrderDetail od) {
		// TODO Auto-generated method stub
		return oddao.list(od);
	}

}
